// **********************************************************************
//                            Project Nitro
//                        ---------------------
//
//  File        : Car.h
//  Description : Car Class
//  Author      : Guillaume Delhumeau <guillaume.delhumeau@gmail.com>
//  License     : GNU General Public License 3
//
// **********************************************************************

#ifndef _CAR_H_
#define _CAR_H_

#include <ClanLib/display.h>
#include "Screen.h"
#include "CarResources.h"
#include "Maths/Matrix.h"

class Car{

public:

	Car();

	void set_resources(CarResources & resources);

	void draw(Screen & screen, float x, float y);

	void update(Screen & screen);

	void events(Screen & screen);

	inline Matrix4f & get_matrix(){return _car_matrix;}

private:

	enum Turning{
		LEFT,
		RIGHT
	};

	enum Gear{
		FORWARD,
		BACKWARD,
		NONE
	};

	CarResources * _p_car_resources;
	Matrix4f _car_matrix;
	
	Vector4f _v_velocity;

	real _velocity;
	real _traction;
	real _brake;
	real _grip;

	CL_Angle _car_rotation;
	CL_Angle _wheel_rotation;
	Turning _last_turning;


	Gear _gear;

	void _compute_velocity(float time_elapsed);

	void _turn(Turning turning, real time_elapsed);

	void _go_straight(real time_elapsed);


};

#endif
